@echooff
%1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit
cd/d "%~dp0"
title 安装JDK
echo.
echo ****************************************
echo.
echo 开始安装JDK，请不要关闭窗⼝......
echo.
echo 请以管理员身份运⾏
echo.
echo 过程可能需要2⾄3分钟
echo.
echo ****************************************
pause
::设置安装路径
set cd=C:\WPGICCard\
set JAVA_HOME=C:\WPGICCard\java\jdk1.8_32
::判断是否已安装
IF EXIST "%JAVA_HOME%"\bin\java.exe (
echo.
echo 发现已安装JDK，即将测试是否可⽤
echo.
goto TEST
)
::安装
start /WAIT C:\WPGICCard\lib\jdk-8u371-windows-i586.exe /qn INSTALLDIR="%JAVA_HOME%"
if %errorlevel% == 0 (
echo.
echo 安装JDK成功，即将配置环境变量
echo.
)
goto SETENV
::配置环境变量
:SETENV
setx /M JAVA_HOME "C:\WPGICCard\java\jdk1.8_32"
setx /M CLASSPATH ".;%%JAVA_HOME%%\lib;%%JAVA_HOME%%\lib\tools.jar;"
setx /M PATH "%%JAVA_HOME%%\bin;%%JAVA_HOME%%\jre\bin;%PATH%;"

::测试是否安装成功
:TEST
echo.
echo 以下提示信息说明JDK安装成功
echo.
echo ========================================
echo java version "1.8.0_131"
echo Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
echo Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)
echo ========================================
echo.
call %JAVA_HOME%\bin\java -version
echo.
goto END
:END
pause
